package com.eddy.liveline.message.service;

import com.eddy.liveline.core.spring.mybatis.pagehelper.Table;
import com.eddy.liveline.message.dao.MessageMapper;
import com.eddy.liveline.message.pojo.Message;
import com.eddy.liveline.message.pojo.MessageTableQuery;
import com.eddy.liveline.requirement.pojo.Requirement;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class MessageServiceImpl implements MessageService {

    @Resource
    private MessageMapper messageMapper;

    @Override
    public boolean batchSave(List<Message> messages) {
        return messageMapper.batchSave(messages);
    }

    @Override
    public boolean deleteById(String id) {
        return messageMapper.deleteById(id);
    }

    @Override
    public boolean deleteByIds(List<String> ids) {
        return messageMapper.deleteByIds(ids);
    }

    @Override
    public Message getById(String id) {
        return messageMapper.getById(id);
    }

    @Override
    public PageInfo<Message> query(MessageTableQuery query) {
        PageHelper.startPage(query.getPageNumber(), query.getPageSize(), true);
        List<Message> list = messageMapper.query(query);
        return new PageInfo<>(list);
    }

    @Override
    public boolean batchUpdate(List<Message> messages) {
        return messageMapper.batchUpdate(messages);
    }
}
